﻿
var regFlag = false;
$(document).ready(function () {

    $("#tabs").tabs();

    //修改用户信息
    $("#MainContent_cph_btn_updUser").click(function () {
        fun_updUserInfo();
    })

    $("#MainContent_cph_btn_updUser").click(function () {
        ValidateInputData();
        if (regFlag == true || regFlag == 1) {
            return true;
        }
        else {
            alert("请检查注册资料是否填写正确");
            return false;
        }
    });

    CheckInput();
})


function fun_updUserInfo() {
    JSONWebServiceA("../Handler/updUserInfo.ashx", { uid: $("#MainContent_cph_hid_uid").val(), email: $("#MainContent_cph_txt_Email").val(), GuideNo: $("#MainContent_cph_txt_GuideNo").val(), isEnglish: $('input[name="isEnglish"]:checked').val(), isLeave: $('input[name="isLeave"]:checked').val() }, function (objJSON) {

        switch (objJSON) {
            case "1":
                alert("修改成功！");
                break;
            case "0":
                alert("修改失败!");
                break;
            case "-1":
                alert("操作失败"); //系统错误
                break;
            default:
                break;
        }
    });
}


function CheckInput() {
    //email
    $("#MainContent_cph_txt_Email").blur(function () {
        OnemailValidate();
    })
}


function OnemailValidate() {
    if ($.trim($("#MainContent_cph_txt_Email").val()).length > 0) {
        var pattern = /^.{1,}[@].{1,}[.][a-zA-Z]{1,}/;
        if (pattern.test($("#MainContent_cph_txt_Email").val()) == false) {
            $("#emailErrImg").css("display", "inline");
            $("#emailErrImg").attr("src", "../App_Themes/images/false.gif");
            $("#emailMsg").html("请填写正确的email！");
            $("#emailMsg").css("color", "Red");
            regFlag = regFlag & false;
        }
        else {
            $("#emailErrImg").css("display", "inline");
            $("#emailErrImg").attr("src", "../App_Themes/images/true.gif");
            $("#emailMsg").html("填写正确！");
            $("#emailMsg").css("color", "Green");

            regFlag = regFlag & true;
        }
    }
    regFlag = regFlag & true;
}


function ValidateInputData() {
    regFlag = true;
    OnemailValidate();
}